let app = getApp()
Component({
    properties: {
        selIndex:Number
      },
      data:{
        loginShow:false
      },
    lifetimes: {
        attached: function () { 
          var that=this
          wx.request({
            url: app.globalData.siteroot,
            data: {
              do:'System_noticecount',
              staff_id:wx.getStorageSync('staff_bind_id')
            },
            success: function(res) {
              var totalNums=parseInt(res.data.info.count)
              wx.request({
                url: app.globalData.siteroot,
                data: {
                  do:'Member_staffInfo',
                  staff_id:wx.getStorageSync('staff_bind_id')
                },
                success: function(res) {
                    var staff_chatid=res.data.info.chatid
                    wx.request({
                      url: app.globalData.siteroot,
                      data: {
                        do:'Buschat_msgList',
                        staff_id:wx.getStorageSync('staff_bind_id'),
                        target:2,
                        chatid:staff_chatid
                      },
                      success: function(res) {
                        var list=res.data.data
                        for (var a = 0; a <list.length; a++) {
                          if(typeof(list[a].num)!='undefined'){
                            totalNums=totalNums+parseInt(list[a].num)
                          }
                        }
                        that.setData({
                          totalNums:totalNums
                        })
                      }
                    })
                }
              })
              
            }
          })
         }
      },
    methods: {
      selNav: function(e) { 
        var id=e.currentTarget.dataset.id
        var n;
        switch (parseInt(id)) {
          case 0:
            n = "../../pages/staff_newIndex/index";
            break;
          case 1:
            n = "../../pages/staff_newReceiveVisitors/index";
            break;
          case 2:
            n = "../../pages/staff_customer/index";
            break;
          case 3:
            n = "../../pages/staff_news/index";
            break;
          case 4:
            n = "../../pages/staff_mine/index";
            break;
          default:
            break;
        }
        wx.redirectTo({
          url:n
        })
    }
    }
});
